home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / buildRenderManipMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.9 KB  |  296 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //
  20. //  Creation Date:    June 11, 1997
  21. //  Author:        cdt
  22. //
  23. //  Procedure Name:
  24. //      buildRenderManipMenu
  25. //
  26. //  Description Name;
  27. //      Script to create the render manip menu.
  28. //
  29. //  Input Value:
  30. //      Parent menu name
  31. //
  32. //  Output Value:
  33. //      None
  34. // 
  35.  
  36. global proc buildRenderManipMenu( string $parent )
  37. {
  38.     setParent -m $parent;
  39.  
  40.     menu -e -deleteAllItems $parent;
  41.  
  42.     // Data to be filled in from selection list.
  43.     //
  44.  
  45.     string $parentName, $objectName, $objectType;
  46.     int $found = false;
  47.  
  48.     // Match cameras, lights, and spot-lights on the selection list.
  49.     //
  50.     string $selected[] = `ls -selection`;
  51.  
  52.     for ($item in $selected) {
  53.         string $shapes[];
  54.  
  55.         if ( !catch( $shapes = `listRelatives -shapes $item` ) ) {
  56.             // List relatives succeeded, item is a DAG object.
  57.  
  58.             if (size($shapes) == 0) {
  59.                 // item is a shape.
  60.                 $shapes[0] = $item;
  61.             }
  62.  
  63.             for ($shape in $shapes) {
  64.                 $objectType = `objectType $shape`;
  65.  
  66.                 if ($objectType == "camera" ||
  67.                     $objectType == "spotLight" ||
  68.                     $objectType == "pointLight" ||
  69.                     $objectType == "volumeLight" ||
  70.                     $objectType == "ambientLight" ||
  71.                     $objectType == "areaLight" ||
  72.                     $objectType == "directionalLight")
  73.                 {
  74.                     $found = true;
  75.                     $parentName = $item;
  76.                     $objectName = $shape;
  77.                     break;
  78.                 }
  79.             }
  80.  
  81.             if ($found)
  82.                 break;
  83.         }
  84.     }
  85.  
  86.     // Create the menu items
  87.     //
  88.  
  89.     if ($objectType == "camera") {
  90.         // Menu item for state
  91.  
  92.         int $hasCameraManip = `renderManip -q -state $objectName`;
  93.  
  94.         menuItem -label $parentName -checkBox $hasCameraManip
  95.             -command ("cameraManipMenuCB true "+$parent+" "+$objectName)
  96.             state;
  97.  
  98.         menuItem -divider true;
  99.  
  100.         // Menu items for components
  101.  
  102.         int $v[] = `renderManip -q -camera $objectName`;
  103.  
  104.         menuItem -label "Center of Interest" -checkBox $v[1]
  105.             -command ("cameraManipMenuCB false "+$parent+" "+$objectName)
  106.             m0;
  107.  
  108.         menuItem -label "Pivot" -checkBox $v[2]
  109.             -command ("cameraManipMenuCB false "+$parent+" "+$objectName)
  110.             m1;
  111.  
  112.         menuItem -label "Clipping Planes" -checkBox $v[3]
  113.             -command ("cameraManipMenuCB false "+$parent+" "+$objectName)
  114.             m2;
  115.  
  116.         menuItem -label "Cycling Index" -checkBox $v[0]
  117.             -command ("cameraManipMenuCB false "+$parent+" "+$objectName)
  118.             m3;
  119.     }
  120.     else if ($objectType == "spotLight") {
  121.         int $hasSpotManip = `renderManip -q -state $objectName`;
  122.  
  123.         menuItem -label $parentName -checkBox $hasSpotManip
  124.             -command  ("spotManipMenuCB true "+$parent+" "+$objectName)
  125.             state;
  126.  
  127.         menuItem -divider true;
  128.  
  129.         int $v[] = `renderManip -q -spotLight $objectName`;
  130.  
  131.         menuItem -label "Center of Interest" -checkBox $v[1]
  132.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  133.             m0;
  134.  
  135.         menuItem -label "Pivot" -checkBox $v[2]
  136.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  137.             m1;
  138.  
  139.         menuItem -label "Cone Angle" -checkBox $v[3]
  140.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  141.             m2;
  142.  
  143.         menuItem -label "Penumbra" -checkBox $v[4]
  144.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  145.             m3;
  146.  
  147.         menuItem -label "Look Through Barn Doors" -checkBox $v[5]
  148.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  149.             m4;
  150.  
  151.         menuItem -label "Decay Regions" -checkBox $v[6]
  152.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  153.             m5;
  154.  
  155.         menuItem -label "Cycling Index" -checkBox $v[0]
  156.             -command ("spotManipMenuCB false "+$parent+" "+$objectName)
  157.             m6;
  158.     }
  159.     else if ($objectType == "pointLight" ||
  160.              $objectType == "volumeLight" ||
  161.              $objectType == "ambientLight" ||
  162.              $objectType == "areaLight" ||
  163.              $objectType == "directionalLight")
  164.     {
  165.         int $hasLightManip = `renderManip -q -state $objectName`;
  166.  
  167.         menuItem -label $parentName -checkBox $hasLightManip
  168.             -command ("lightManipMenuCB true "+$parent+" "+$objectName)
  169.             state;
  170.  
  171.         menuItem -divider true;
  172.  
  173.         int $v[] = `renderManip -q -light $objectName`;
  174.  
  175.         menuItem -label "Center of Interest" -checkBox $v[1]
  176.             -command ("lightManipMenuCB false "+$parent+" "+$objectName)
  177.             m0;
  178.  
  179.         menuItem -label "Pivot" -checkBox $v[2]
  180.             -command ("lightManipMenuCB false "+$parent+" "+$objectName)
  181.             m1;
  182.  
  183.         menuItem -label "Cycling Index" -checkBox $v[0]
  184.             -command ("lightManipMenuCB false "+$parent+" "+$objectName)
  185.             m2;
  186.     }
  187.     else {
  188.         menuItem -l "Select Camera or Light" -en false;
  189.     }
  190. }
  191.  
  192. global proc cameraManipMenuCB(
  193.     int $stateChanged, string $parent, string $object )
  194. {
  195.     setParent -m $parent;
  196.  
  197.     int $state, $v[5];
  198.  
  199.     if ($stateChanged) {
  200.         $state = `menuItem -q -checkBox state`;
  201.  
  202.         renderManip -e -state $state $object;
  203.     }
  204.     else {
  205.         $v[0] = `menuItem -q -checkBox m3`;
  206.         $v[1] = `menuItem -q -checkBox m0`;
  207.         $v[2] = `menuItem -q -checkBox m1`;
  208.         $v[3] = `menuItem -q -checkBox m2`;
  209.         $v[4] = false;
  210.  
  211.         renderManip -e -camera $v[0] $v[1] $v[2] $v[3] $v[4] $object;
  212.     }
  213.  
  214.     // A change in state will change component visibility
  215.  
  216.     $state = `renderManip -q -state $object`;
  217.     menuItem -e -checkBox $state state;
  218.  
  219.     $v = `renderManip -q -camera $object`;
  220.     menuItem -e -checkBox $v[0] m3;
  221.     menuItem -e -checkBox $v[1] m0;
  222.     menuItem -e -checkBox $v[2] m1;
  223.     menuItem -e -checkBox $v[3] m2;
  224. }
  225.  
  226. global proc spotManipMenuCB(
  227.     int $stateChanged, string $parent, string $object )
  228. {
  229.     setParent -m $parent;
  230.  
  231.     int $state, $v[7];
  232.  
  233.     if ($stateChanged) {
  234.         $state = `menuItem -q -checkBox state`;
  235.  
  236.         renderManip -e -state $state $object;
  237.     }
  238.     else {
  239.         $v[0] = `menuItem -q -checkBox m6`;
  240.         $v[1] = `menuItem -q -checkBox m0`;
  241.         $v[2] = `menuItem -q -checkBox m1`;
  242.         $v[3] = `menuItem -q -checkBox m2`;
  243.         $v[4] = `menuItem -q -checkBox m3`;
  244.         $v[5] = `menuItem -q -checkBox m4`;
  245.         $v[6] = `menuItem -q -checkBox m5`;
  246.  
  247.         renderManip -e
  248.             -spotLight $v[0] $v[1] $v[2] $v[3] $v[4] $v[5] $v[6] $object;
  249.     }
  250.  
  251.     // A change in state will change component visibility
  252.  
  253.     $state = `renderManip -q -state $object`;
  254.     menuItem -e -checkBox $state state;
  255.  
  256.     $v = `renderManip -q -spotLight $object`;
  257.     menuItem -e -checkBox $v[0] m6;
  258.     menuItem -e -checkBox $v[1] m0;
  259.     menuItem -e -checkBox $v[2] m1;
  260.     menuItem -e -checkBox $v[3] m2;
  261.     menuItem -e -checkBox $v[4] m3;
  262.     menuItem -e -checkBox $v[5] m4;
  263.     menuItem -e -checkBox $v[6] m5;
  264. }
  265.  
  266. global proc lightManipMenuCB(
  267.     int $stateChanged, string $parent, string $object )
  268. {
  269.     setParent -m $parent;
  270.  
  271.     int $state, $v[3];
  272.  
  273.     if ($stateChanged) {
  274.         $state = `menuItem -q -checkBox state`;
  275.  
  276.         renderManip -e -state $state $object;
  277.     }
  278.     else {
  279.         $v[0] = `menuItem -q -checkBox m2`;
  280.         $v[1] = `menuItem -q -checkBox m0`;
  281.         $v[2] = `menuItem -q -checkBox m1`;
  282.  
  283.         renderManip -e -light $v[0] $v[1] $v[2] $object;
  284.     }
  285.  
  286.     // A change in state will change component visibility
  287.  
  288.     $state = `renderManip -q -state $object`;
  289.     menuItem -e -checkBox $state state;
  290.  
  291.     $v = `renderManip -q -light $object`;
  292.     menuItem -e -checkBox $v[0] m2;
  293.     menuItem -e -checkBox $v[1] m0;
  294.     menuItem -e -checkBox $v[2] m1;
  295. }
  296.